# Buscar data, hacer graficos

# # # get ip source packages

# load
src <- read.table('us.ipsrc.0', header=T)

# info
name = "us.ipsrc.png"
print(src)

# pie chart
slices <- src$frec
labs <- src$ip
porcen <- round(slices/sum(slices)*100, digits=2)

cant <- paste("[#",slices,sep="") # add cant to labels
cant <- paste(cant,"]",sep="")
labs <- paste(labs, cant)

porcen <- paste("(", porcen, sep="") # add percents to labels 
porcen <- paste(porcen, "%)", sep="") 
labs <- paste(labs, porcen) 

# flush
png(filename=name, width=800, height=600, bg="white")
pie(slices, labels = labs, col=rainbow(length(labs)),
    main="IPs de envío de paquetes ARP sobre sniffing propio de 20 minutos")
dev.off()

# --------------------------------------------------------------------------

# # # get ip destination packages

# load
dst <- read.table('us.ipdst.0', header=T)

# info
name = "us.ipdst.png"
print(dst)

# pie chart
slices <- dst$frec
labs <- dst$ip
porcen <- round(slices/sum(slices)*100, digits=2)

cant <- paste("[#",slices,sep="") # add cant to labels
cant <- paste(cant,"]",sep="")
labs <- paste(labs, cant)

porcen <- paste("(", porcen, sep="") # add percents to labels 
porcen <- paste(porcen, "%)", sep="") 
labs <- paste(labs, porcen) 

# flush
png(filename=name, width=800, height=600, bg="white")
pie(slices, labels = labs, col=rainbow(length(labs)),
    main="IPs de recepción de paquetes ARP sobre sniffing propio de 20 minutos")
dev.off()
